Error handling + Code reformatting