Adding helper functions and fixing issue when id not found