low level code for scala