corrected/better solution