Added filepath error check