added better error handling in pms