Improvements on code