Remove debug statement
Use functions
Add error checking