added $ and moved some parts around