Improvements suggested by @saivann