started porting sources function