cleaned  up functions