Added error handling to MOPS
First draft of main script