more things work, optimized code slightly