changed code a bit