Fixed Error & Cleanup code