Corrected the code after reading less ambigous specification I ordered.