optimization
corrected time and memory issues