Fixed syntax errors
Fixed return values
Removed irrelevant functio
Added error handling