Separated out and removed useless code