modified based on @ElBrogrammers comment