Much better approach than the first submission