Simplifying code as requested by @ichernev