edited code to be more efficient