Corrected errors in calculation
Revised to get rid of wrong solutions and clear up