changed code a little