some errors in code and implementing guards