Feature/issue 66

Fixes issue by porting code from iOS