changed code a bit still the same functionality