changes based on a stackoverflow answer