added logic and functionality

i hope it works, works kind of fine on my phone

Signed-off-by: Liew Zhao Wei <zhaoweiliew@gmail.com>