improved things, added SD code

need to improve SD code. its probably wrong..