Fixed more returns and optimized

Fixed more returns and optimized