fixed bug, made script nicer