Adjusted code flow, made error better