changed code style a little, code does not work properly