Added rudimental error handling