Fixed syntax errors and refactored for better error checking
0.2.39